const mongoose = require('mongoose');
const dbconfig = require("../config/config").db
const url = `mongodb://${dbconfig.username}:${dbconfig.password}@${dbconfig.url}/${dbconfig.db}`
const options = {
  useNewUrlParser: true,
  useUnifiedTopology: true,
};

const connect = () => {
  mongoose.connect(url, options).then(() => {
    console.log('Connected to database!');
  }).catch(err => {
    console.log('Error connecting to database: ', err.message);
  });
}

module.exports = connect;